package hmvc4gwt.client.controller;

/*
 * Copyright 2008 Jens Meiss
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License. 
 * You may obtain a copy of the License at 
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import hmvc4gwt.client.component.IComponent;
import hmvc4gwt.client.component.IInitializeAble;
import hmvc4gwt.client.component.ITerminateAble;
import hmvc4gwt.client.event.IEvent;
import hmvc4gwt.client.event.IEventListener;
import hmvc4gwt.client.model.IModel;
import hmvc4gwt.client.view.IView;

/**
 * This Interface defines the Controller-Part of this HMVC-Implementation
 * 
 * @author jens.meiss
 *
 */
public interface IController extends IInitializeAble, ITerminateAble, IEventListener {
	
	/**
	 * adds an Controller-Child-Component
	 * @param controller
	 * @return
	 */
	public IComponent addChildComponent(IController controller);
	
	/**
	 * adds an Controller-Model-Child-Component
	 * @param controller
	 * @param model
	 * @return
	 */
	public IComponent addChildComponent(IController controller, IModel model);
	
	/**
	 * adds an Controller-Model-View-Child-Component
	 * @param controller
	 * @param model
	 * @param view
	 * @return
	 */
	public IComponent addChildComponent(IController controller, IModel model,
			IView view);
	
	/**
	 * adds an Controller-View-Child-Component
	 * @param controller
	 * @param view
	 * @return
	 */
	public IComponent addChildComponent(IController controller, IView view);
	
	/**
	 * fires the Event to the given direction
	 * @param event
	 * @param up
	 * @param local
	 * @param down
	 */
	public void fireEvent(IEvent event, boolean up, boolean local,
			boolean down);
	
	/**
	 * fires the Event down
	 * @param event
	 */
	public void fireEventDown(IEvent event);
	
	/**
	 * fires the Event up
	 * @param event
	 */
	public void fireEventUp(IEvent event);
	
	/**
	 * fires the Event to the local listeners
	 * @param event
	 */
	public void fireEventLocal(IEvent event);
	
	/**
	 * work-a-round for the not implemented Object.getClass()-Method
	 * 
	 * @return the Class-Object of the Controller-Implementation, i.e. IControllerImpl.class
	 */
	public Class getClassOfObject();
	
	/**
	 * returns the Component of the Controller
	 * @param component
	 */
	public IComponent getComponent();
	
	/**
	 * @return the Model of this Component
	 */
	public IModel getModel();
	
	/**
	 * @return the View of this Component
	 */
	public IView getView();
	
	/**
	 * registers an listener for the event
	 * @param classOfEvent
	 * @param listener
	 */
	public void register(Class classOfEvent, IEventListener listener);
	
	/**
	 * setter for the Component-Object
	 * @param component
	 */
	public void setComponent(IComponent component);
}
